package coreSimulation;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;


public class DeskController {
	
	DeskUI deskUI;
	DropOffDesk desk;

	public DeskController(DeskUI deskUI, DropOffDesk desk) {
		this.deskUI = deskUI;
		this.desk = desk;
		deskUI.setCloseDeskButtonEnabled(false);
		deskUI.setVisible(true);
		deskUI.addCloseDeskButtonListener(new CloseDeskController());
				
		Random random = new Random();
		Thread thread = new Thread(desk);
		try {
			Thread.sleep(random.nextInt(10000));
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		thread.start();
		deskUI.setCloseDeskButtonEnabled(true);
		deskUI.setTitle("Passenger Drop Off Desk - OPEN");
		

	}
	
	class CloseDeskController implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			desk.setDeskIsOpen(false);
			deskUI.setCloseDeskButtonEnabled(false);
			deskUI.setTitle("Passenger Drop Off Desk - CLOSED");
			
		}
	}
	
	

}
